package com.glodon.paas.document.dao.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.glodon.paas.document.api.bean.Revision;
import com.glodon.paas.document.api.bean.Share;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;

@Entity(value = "share", noClassnameStored = true)
public class ShareEntity {

    public static Share getDto(ShareEntity e) {
        if (e == null) {
            return null;
        } else {
            Share d = new Share();
            d.setCreatedTime(e.getCreatedTime());
            d.setFileId(e.getFileId());
            d.setId(e.getId());
            d.setPrivilege(e.getPrivilege());
            d.setSharedUserId(e.getSharedUserId());
            d.setToUserId(e.getToUserId());
            return d;
        }
    }

    public static List<Share> getDtos(List<ShareEntity> es) {
        if (es == null) {
            return null;
        } else {
            List<Share> ds = new ArrayList<Share>();
            for (ShareEntity e : es) {
                ds.add(getDto(e));
            }
            return ds;
        }
    }

    @Id
    private String  id;

    private String  fileId;

    private String  sharedUserId;

    private String  toUserId;

    private Integer privilege;

    private Date    createdTime;

    private Integer shareType;

    public String getSharedUserId() {
        return sharedUserId;
    }

    public void setSharedUserId(String sharedUserId) {
        this.sharedUserId = sharedUserId;
    }

    public String getToUserId() {
        return toUserId;
    }

    public void setToUserId(String toUserId) {
        this.toUserId = toUserId;
    }

    public Integer getPrivilege() {
        return privilege;
    }

    public void setPrivilege(Integer privilege) {
        this.privilege = privilege;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public Integer getShareType() {
        return shareType;
    }

    public void setShareType(Integer shareType) {
        this.shareType = shareType;
    }
}
